#pragma once

#include "compileconfig.h"

#ifdef MW_COMPILE_WITH_OPENGL

#include "core.h"
#include "SColor.h"
#include "SMaterial.h"
#include "IShader.h"

class COpenGLShaderServices;

class COpenGL_PS15
{
private:
	DISALLOW_COPY_AND_ASSIGN(COpenGL_PS15);

public:
	COpenGL_PS15() {}

	static void Terrain_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void UI_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void Default_setShaderConst_T1(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void Default_setShaderConst_T2(IPixelShader* ps, const SMaterial& material, uint32_t pass);

	static void DiffuseT1_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void DiffuseT2_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void DiffuseT3_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);

	static void MapObjOpaque_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void MapObj_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void MapObjTwoLayer_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);
	static void MapObjTwoLayerOpaque_setShaderConst(IPixelShader* ps, const SMaterial& material, uint32_t pass);

public:
	void loadAll(COpenGLShaderServices* shaderServices);

	bool loadPShaderHLSL(COpenGLShaderServices* shaderServices, E_PS_TYPE type, E_PS_MACRO macro);

	struct SPixelShaderEntry
	{
		E_PS_TYPE psType;
		string64	path;
		PSHADERCONSTCALLBACK callback;
	};

private:

	struct Common_CB
	{
		float				params[4];		//0: alphatest, 1: alpharef
	};

	struct Terrain_CB
	{
		float params[4];		//0: numTextures
		SColorf		fogColor;
	};

	struct Diffuse_CB
	{	
		SColorf		FogColor;
		float				params[4];		//0: alphatest, 1: alpharef
	};

	struct MapObjDiffuse_CB
	{
		float		LightDir[4];
		SColorf			LightColor;
		SColorf			Diffuse;
		SColorf			Emissive;
		SColorf			Specular;
		SColorf			FogColor;
		float			params[4];			//0: alphatest, 1: ref
	};
};


#endif